﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Lawyer.Web.Admin
{
    public partial class admin_agencyadd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Lawyer.Model.AgencyInfo model = CreateFromForm();
            Lawyer.BLL.AgencyInfo bll = new Lawyer.BLL.AgencyInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "success！", "admin_agencylist.aspx");

        }
        private Lawyer.Model.AgencyInfo CreateFromForm()
        {
            string Name = this.txbUserName.Text;
            string Email = this.txbEmail.Text;
            double AgencyRate = Double.Parse(this.txbAgencyRate.Text);
            string City = this.txtCity.Text;
            string Telphone = this.txtTelphone.Text;
            string Fax = this.txtFax.Text;
            string Address = this.txtAddress.Text;

            

            Lawyer.Model.AgencyInfo model = new Lawyer.Model.AgencyInfo();
            model.Name = Name;
            model.Email = Email;
            model.AgencyRate = AgencyRate;
            model.AgencyRate = 0;//初始化
            model.City = City;
            model.Telphone = Telphone;
            model.Fax = Fax;
            model.Address = Address;

            model.AgencyID = Guid.NewGuid().ToString();
            model.CreatedBy = Session["UserID"].ToString();
            model.CreatedDate = DateTime.Now;
            model.Status = 0;//0=>Normal,1=>Deleted
            model.Updatedby = Session["UserID"].ToString();
            model.UpdatedDate = DateTime.Now;
            return model;

        }
    }
}
